let caseArr = document.querySelectorAll(".cases")
let navArr = document.querySelectorAll(".navright div")
let time
let y = 0
console.log(caseArr);

navArr.forEach(function (v,i){
    v.onclick = function (){
        // window.scrollTo(0,caseArr[i].offsetTop)
        clearInterval(time)
        let num = window.scrollY - caseArr[i].offsetTop
        // clearInterval(time)
        if (num >= 0) {
            time = setInterval(function (){
                scrollTo(0,window.scrollY-5)
                if (window.scrollY<=caseArr[i].offsetTop) {
                    clearInterval(time)
                }
            },15)
        } else if (num < 0) {
            time = setInterval(function (){
                scrollTo(0,window.scrollY+5)
                if (window.scrollY>caseArr[i].offsetTop) {
                    clearInterval(time)
                }
                if (window.scrollY>1600) {
                    clearInterval(time)
                }
            },15)
        }
    }
})
